import Vue from 'vue'
import moment from 'moment'
import { jobList } from '@/common/utils/const'

Vue.filter('formatDate', function(input, fmtstring = 'YYYY-MM-DD HH:mm:ss') {
  if (typeof input !== 'number') input = Number(input)
  return moment(input).format(fmtstring)
})

Vue.filter('formatSex', function(val) {
  switch(val) {
    case 1:
      return '男'
    case 2:
      return '女'
  }
})

Vue.filter('formatLevel', function(val) {
  switch(val) {
    case 1:
      return '机关党委'
    case 2:
      return '党支部'
    case 3:
      return '党小组'
  }
})

Vue.filter('formatJobType', function(val) {
  return jobList[val].name || val
})
